//
// Created by 123 on 2025/1/2.
//
#include "iostream"
using namespace std;

class Base{
public:
    int a;
    Base(){
        this->a = 1;
        this->b = 2;
        this->c = 3;
    }
protected:
    int b;
private:
    int c;
};
//公共继承,子类内可访问public和protected
/**
 * 公共继承
 * 子类内可访问public和protected 类外可访问public
 */
class pubExtend:public Base{

public:
    void func(){
        cout << "a==" << a << endl;
        cout << "b==" << b << endl;
//        cout << "c==" << c << endl;
    }
};
void testPub(){
    pubExtend pub;
    cout << pub.a << endl;
//    cout << pub.b << endl;
//    cout << pub.c << endl;
}

class proExtend : protected Base{
public:
    void func(){
        cout << "a==" << a << endl;
        cout << "b==" << b << endl;
//        cout << "c==" << c << endl;
    }
};
void testPro(){
    proExtend pro;
//    cout << pro.a << endl;
//    cout << pub.b << endl;
//    cout << pub.c << endl;
}

class priExtend:private  Base{
public:
    void func(){
        cout << "a==" << a << endl;
        cout << "b==" << b << endl;
//        cout << "c==" << c << endl;
    }
};
void testPri(){
    priExtend pri;
    //    cout << pro.a << endl;
//    cout << pub.b << endl;
//    cout << pub.c << endl;
}

class GrandExtend : private priExtend{
public:
    void func(){
        //priExtend是私有继承，所以继承priExtend的属性在GrandExtend中都无法访问到
    }
};


int main079(){
    pubExtend pub;
    pub.func();
    testPub();

    proExtend pro;
    pro.func();
    testPro();


    return 0;
}